"""Build pool library"""


def scons():
    """Execute build"""
    Import('env', 'prereqs', 'libdaos_tgts')

    env.AppendUnique(LIBPATH=[Dir('.')])
    env.AppendUnique(CPPPATH=[Dir('../mgmt').srcnode()])
    denv = env.Clone()

    denv.require('protobufc')

    common = denv.SharedObject(['rpc.c'])

    # dc_pool: Pool Client
    libdaos_tgts.extend(denv.SharedObject(['cli.c']) + common)

    if not prereqs.server_requested():
        return

    senv = denv.Clone()
    senv.require('argobots')
    # ds_pool: Pool Server
    ds_pool = senv.d_library('pool',
                             ['srv.c', 'srv_pool.c', 'srv_layout.c',
                              'srv_target.c', 'srv_util.c', 'srv_iv.c',
                              'srv_cli.c',
                              'srv_pool_scrub_ult.c', 'srv_pool_map.c',
                              'srv_metrics.c', 'srv_pool_chkpt.c',
                              'srv_pool_check.c', common],
                             install_off="../..")
    senv.Install('$PREFIX/lib64/daos_srv', ds_pool)


if __name__ == "SCons.Script":
    scons()
